1

00:00:01,060  -->  00:00:07,440
In the previous video, we already create a
configure menu. Now, in this video, we are

2

00:00:07,660  -->  00:00:15,460
going to create a very config menu. Okay let’s
just start. Open the visual studio code.

3

00:00:15,460  -->  00:00:22,660
First, let’s create a new url, in this case
I will create a verify_config url.

4

00:00:25,920  -->  00:00:31,980
And this url will be redirected to verify_config function
inside viws.py.

5

00:00:32,580  -->  00:00:39,180
Now let’s create verify_config function
inside views.py. I will copy and paste the

6

00:00:39,180  -->  00:00:41,160
script from my note.

7

00:00:49,360  -->  00:00:55,920
Okay let’s understand this cript. If we
see here, the script is similar with configure

8

00:00:55,920  -->  00:01:02,840
function that we have created in the previous
video. Here we have an if statement.

9

00:01:03,060  -->  00:01:08,680
if request.method is post, then this block script will be executed.

10

00:01:11,200  -->  00:01:16,560
But if the request is get, this block script will be executed.

11

00:01:17,340  -->  00:01:23,840
If we see here, the template file that we
use here is the same template with configure function

12

00:01:23,840  -->  00:01:26,600
which is config.html.

13

00:01:27,420  -->  00:01:32,820
Okay now let’s understand the script if
the request.method is post.

14

00:01:33,540  -->  00:01:41,820
Here we define a blank list, later we will use this list
to save the result of the verify command.

15

00:01:41,820  -->  00:01:49,720
Here we have selected_device_id, mikrotik_command,
and cisco_command. Thi is the same thing with

16

00:01:49,720  -->  00:01:51,340
the previous video.

17

00:01:52,020  -->  00:01:59,600
Then we do looping to the selected_device_id
here. We login to the device using paramiko.

18

00:02:00,040  -->  00:02:05,820
If the device is mikrotik, we looping to the
mikrotik_command and send the command to the

19

00:02:05,820  -->  00:02:13,620
mikrotik using exec_command. Then the output
of the command will be saved to stdout variable.

20

00:02:14,180  -->  00:02:16,760
We don’t need time sleep here.

21

00:02:17,120  -->  00:02:21,740
Then, we append the result of the command
to the result list.

22

00:02:21,920  -->  00:02:29,060
If the device is cisco, we do invoke shell
and send the command “terminal length 0”.

23

00:02:31,180  -->  00:02:36,780
After that we looping to the  cisco_command and
send the command to the devices.

24

00:02:37,360  -->  00:02:43,460
Don’t forget to always use time sleep if we doing network automation on cisco using paramiko.

25

00:02:43,460  -->  00:02:47,900
Then we save the output of the command to the output
variable.

26

00:02:48,280  -->  00:02:52,040
Last, we append the output to the result list.

27

00:02:52,300  -->  00:02:57,180
Here we join the result list using ‘\n’
or enter.

28

00:02:57,900  -->  00:03:06,620
Here we return a template file named verify_result.html,
and we use result as a context.

29

00:03:07,200  -->  00:03:14,160
Now let’s create the template file. I already
upload the verify_result.html file to the

30

00:03:14,160  -->  00:03:21,000
resource section, so you can just download
it and put it to the templates directory.

31

00:03:25,520  -->  00:03:32,820
Okay now we have verify_result.html file here.
But the name is not correct

32

00:03:36,160  -->  00:03:40,140
we must have an underscore here, not dash.

33

00:03:47,480  -->  00:03:55,900
Okay now let’s open the browser and navigate
to 127.0.0.1:8000/verify_config.

34

00:03:56,680  -->  00:04:03,540
Here we can see the verify config menu. We can choose
the target devices that we want to verify

35

00:04:03,540  -->  00:04:08,880
and put the command to verify configuration
on mikrotik or cisco device here.

36

00:04:09,400  -->  00:04:16,760
Okay now we have successfully create a verify
config menu. We will not doing the test now,

37

00:04:16,760  -->  00:04:19,920
we will doing the test later in the next video.

38

00:04:20,300  -->  00:04:23,980
But before doing the test, we will create
a log menu first.

39

00:04:24,480  -->  00:04:27,240
Thankyou for watching and see you on the next video!
